{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 暂时不考虑车架号的含义，用字符串代替即可\n",
    "- 创建一个空集合,这个集合用生成车架号的，按理来说，只需要生成一次即可\n",
    "- 如果多次运行，就会导致车架号一致变化，不便于观察我们的需求是否达到\n",
    "- 所以这里将他单独提出来，生成之后将数据存到csv表中\n",
    "- 因为要模拟多天的数据，考虑到不是车不是每天都开出的，所以将车架号分开存，通过随机选取其中的2个空间车架号，就可以了了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "import pandas as pd\n",
    "\n",
    "def get_vin(vin_set:set,number:int) -> set:\n",
    "    '''\n",
    "    用来生成指定数量的车架号\n",
    "\n",
    "    param:vin_set  一个集合,用来接收数据\n",
    "    param:number    生成多少量车的数据\n",
    "    return: 返回一个集合\n",
    "    '''\n",
    "    for i in range(number):\n",
    "        vin = ''.join(random.choices('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', k=17))\n",
    "        if vin not in vin_set:\n",
    "            vin_set.add(vin)    \n",
    "    return vin_set\n",
    "\n",
    "\n",
    "vin_set = set() # 创建一个空集合\n",
    "\n",
    "# 生成200量车的车架号\n",
    "vins = get_vin(vin_set,100)\n",
    "\n",
    "# 创建 DataFrame 对象\n",
    "df = pd.DataFrame(vins, columns=[\"vin\"])\n",
    "\n",
    "df.to_csv(\"vins5.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.9.13 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "79c2bc36f36ebca92fe5f3c73355a3866f3a34a4fd0b1d43087d5313dd5fd5ff"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
